package com.keruyun.portal.whitelist.gateway.conf;

import com.keruyun.portal.whitelist.gateway.filter.PortalRibbonClient;
import com.keruyun.portal.whitelist.gateway.lb.PortalRoundRobinRule;
import com.keruyun.portal.whitelist.gateway.lb.PortalVersionLoadBalancer;
import com.keruyun.portal.whitelist.gateway.service.PortalWhitelistService;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * Description: com.keruyun.portal.whitelist.gateway.conf
 * </p>
 * date：2018/7/3
 * email:crowhyc@163.com
 *
 * @author Dean.Hwang
 */
@Configuration
public class GatewayFilterConfig {
    @Bean
    public PortalRoundRobinRule portalRoundRobinRule() {
        return new PortalRoundRobinRule();
    }

    @Bean
    public PortalVersionLoadBalancer portalVersionLoadBalancer(SpringClientFactory springClientFactory, PortalRoundRobinRule portalRoundRobinRule) {
        return new PortalVersionLoadBalancer(springClientFactory, portalRoundRobinRule);
    }

    @Bean
    public PortalRibbonClient portalRibbonClient(PortalVersionLoadBalancer portalVersionLoadBalancer, PortalWhitelistService portalWhitelistService) {
        return new PortalRibbonClient(portalVersionLoadBalancer, portalWhitelistService);
    }
}
